package org.spiderflow.config;

public class RestResultGenerator {

    public static <T> ResponseResult<T> genResult(String msg){
        ResponseResult<T> result = new ResponseResult<T>();
        result.setSuccess(true);
        result.setMessage(msg);
        return result;
    }

    public static <T> ResponseResult<T> genErrorResult(String msg){
        ResponseResult<T> result = new ResponseResult<T>();
        result.setSuccess(false);
        result.setMessage(msg);
        return result;
    }

    public static <T> ResponseResult<T> genResult(T data,String msg){
        ResponseResult<T> result = new ResponseResult<T>();  
        result.setData(data);  
        result.setSuccess(true);  
        result.setMessage(msg);
        return result;  
    }

    public static <T> ResponseResult<T> genErrorResult(T data,String msg){
        ResponseResult<T> result = new ResponseResult<T>();
        result.setData(data);
        result.setSuccess(false);
        result.setMessage(msg);
        return result;
    }

    public static <T> ResponseResult<T> genErrorResult(GlobalErrorInfoEnum gei){
        ResponseResult<T> result = new ResponseResult<T>();
        result.setData(null);
        result.setSuccess(false);
        result.setMessage(gei.getMessage());
        result.setCode(gei.getCode());
        return result;
    }


    public static <T> ResponseResult<T> genResult(String code,T data,String msg){
        ResponseResult<T> result = new ResponseResult<T>();
        result.setData(data);
        result.setSuccess(true);
        result.setMessage(msg);
        result.setCode(code);
        return result;
    }

    public static <T> ResponseResult<T> genErrorResult(String code,T data,String msg){
        ResponseResult<T> result = new ResponseResult<T>();
        result.setData(data);
        result.setSuccess(false);
        result.setMessage(msg);
        result.setCode(code);
        return result;
    }

}
